import request from '@/utils/request'

const userApi = {
  Login: '/login?terminal_type=PC',
  phoneLogin: '/phoneLogin?terminal_type=PC',
  getVerificationCode: '/getVerificationCode',
  Logout: '/logout',
  // get my info
  UserInfo: '/getInfo',
  UserMenu: '/getRouters'
}

export function login (parameter) {
  return request({
    url: userApi.Login,
    method: 'post',
    data: parameter
  })
}
// 手机验证码登录
export function phoneLogin (parameter) {
  return request({
    url: userApi.phoneLogin,
    method: 'post',
    data: parameter
  })
}
// 获取验证码
export function getVerificationCode (parameter) {
  return request({
    url: userApi.getVerificationCode,
    method: 'get',
    params: parameter
  })
}

export function getInfo () {
  return request({
    url: userApi.UserInfo,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function getCurrentUserNav () {
  return request({
    url: userApi.UserMenu,
    method: 'get'
  })
}

export function logout () {
  return request({
    url: userApi.Logout,
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
